package www.openteam.com.presenter.qualityCntrl;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.IPQCBadReason;
import www.openteam.com.bean.IPQCCheckItem;
import www.openteam.com.bean.IPQCDispose;
import www.openteam.com.contract.qualityCntrl.IPQC00Contract;
import www.openteam.com.model.qualityCntrl.IPQC00Model;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.qualityCntrl.IPQC00Fragment;

/**
 * Created by Administrator on 2018/1/29 0029.
 */

public class IPQC00Presenter extends BasePresenter<IPQC00Fragment>
implements IPQC00Contract.IPQC00Presenter{
    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new IPQC00Model());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("IPQC00Presenter", models[0]);
        return hashMap;
    }

    @Override
    public void findCheckItem() {
        ((IPQC00Model)getiModelMap().get("IPQC00Presenter")).findCheckItem(new IPQC00Model.CheckItemListener() {
            @Override
            public void success(IPQCCheckItem ipqcCheckItem) {
                getIView().findCheckItem(ipqcCheckItem);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findBadReason() {
        ((IPQC00Model)getiModelMap().get("IPQC00Presenter")).findBadReason(new IPQC00Model.BadReasonListener() {
            @Override
            public void success(IPQCBadReason ipqcCheckItem) {
                getIView().findBadReason(ipqcCheckItem);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }

    @Override
    public void findDispose() {
        ((IPQC00Model)getiModelMap().get("IPQC00Presenter")).findDispose(new IPQC00Model.DisposeListener() {
            @Override
            public void success(IPQCDispose ipqcCheckItem) {
                getIView().findDispose(ipqcCheckItem);
            }

            @Override
            public void fail(Throwable e) {
                getIView().fail(e.getMessage());
            }
        });
    }
}
